1 Introduction

In this notebook we will plot the scrublet doublet scores on the UMAPs computed in the previous notebook.

2 Pre-processing

2.1 Load packages

library(Seurat)
## Attaching SeuratObject
library(Signac)
library(tidyverse)
## Registered S3 method overwritten by 'cli':
##   method     from         
##   print.boxx spatstat.geom
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## x purrr::reduce() masks Signac::reduce()

2.2 Load data

# Paths
path_to_data <-("/Users/mlromeror/Documents/multiome_tonsil_Lucia/results/R_objects/8.tonsil_multiome_integrated_using_wnn.rds")
tonsil_integrated <- readRDS(path_to_data)

2.3 Parameters

# Thresholds
max_doublet_score_rna <- 0.3

3 Doublet score

3.1 Scrublet doublet score

hist <- tonsil_integrated@meta.data %>%
  ggplot(aes(doublet_scores)) +
    geom_histogram(bins = 30) +
    geom_vline(
      xintercept = 0.3,
      linetype = "dashed",
      color = "red"
    ) +
    xlab("Doublet Score (RNA)") +
    theme_bw() +
    theme(
      axis.title = element_text(size = 13),
      axis.text = element_text(size = 11)
    )
hist

3.2 Projection

3.2.1 RNA-driven UMAP

# Plot
feat_plot1 <- FeaturePlot(
  tonsil_integrated,
  features = "doublet_scores",
  reduction = "umap.atac",
  pt.size = 0.1
)+ ggtitle('scATAC UMAP doublet scores') 

dim_plot1   <- DimPlot(
  tonsil_integrated,
  group.by = "predicted_doublets",
  reduction = "umap.atac",
  pt.size = 0.1
) + ggtitle('scATAC UMAP predicted doublet') 
feat_plot1

dim_plot1

3.2.2 RNA-driven UMAP

feat_plot3 <- FeaturePlot(
  tonsil_integrated,
  features = "doublet_scores",
  reduction = "umap.rna",
  pt.size = 0.1
) + ggtitle('scRNA UMAP doublet scores') 

dim_plot2 <- DimPlot(
  tonsil_integrated,
  group.by = "predicted_doublets",
  reduction = "umap.rna",
  pt.size = 0.1
)+ ggtitle('scRNA UMAP predicted doublets ') 
feat_plot3

dim_plot2

3.3 Joint Multiome

feat_plot4 <- FeaturePlot(
  tonsil_integrated,
  features = "doublet_scores",
  reduction = "umap",
  pt.size = 0.1
)+ ggtitle('Joint UMAP doublet scores') 

dim_plot4 <- DimPlot(
  tonsil_integrated,
  group.by = "predicted_doublets",
  reduction = "umap",
  pt.size = 0.1
)+ ggtitle('Joint UMAP predicted doublets') 
feat_plot4

dim_plot4

4 Session Information

sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] forcats_0.5.1      stringr_1.4.0      dplyr_1.0.7        purrr_0.3.4       
##  [5] readr_2.1.1        tidyr_1.1.4        tibble_3.1.6       ggplot2_3.3.5     
##  [9] tidyverse_1.3.1    Signac_1.5.0       SeuratObject_4.0.4 Seurat_4.0.6      
## [13] BiocStyle_2.22.0  
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1           backports_1.4.1        fastmatch_1.1-3       
##   [4] plyr_1.8.6             igraph_1.2.10          lazyeval_0.2.2        
##   [7] splines_4.1.2          BiocParallel_1.28.3    listenv_0.8.0         
##  [10] scattermore_0.7        SnowballC_0.7.0        GenomeInfoDb_1.30.0   
##  [13] digest_0.6.29          htmltools_0.5.2        magick_2.7.3          
##  [16] fansi_0.5.0            magrittr_2.0.1         tensor_1.5            
##  [19] cluster_2.1.2          ROCR_1.0-11            tzdb_0.2.0            
##  [22] globals_0.14.0         Biostrings_2.62.0      modelr_0.1.8          
##  [25] matrixStats_0.61.0     docopt_0.7.1           spatstat.sparse_2.1-0 
##  [28] colorspace_2.0-2       rvest_1.0.2            ggrepel_0.9.1         
##  [31] haven_2.4.3            xfun_0.29              sparsesvd_0.2         
##  [34] crayon_1.4.2           RCurl_1.98-1.5         jsonlite_1.7.2        
##  [37] spatstat.data_2.1-2    survival_3.2-13        zoo_1.8-9             
##  [40] glue_1.6.0             polyclip_1.10-0        gtable_0.3.0          
##  [43] zlibbioc_1.40.0        XVector_0.34.0         leiden_0.3.9          
##  [46] future.apply_1.8.1     BiocGenerics_0.40.0    abind_1.4-5           
##  [49] scales_1.1.1           DBI_1.1.1              miniUI_0.1.1.1        
##  [52] Rcpp_1.0.7             viridisLite_0.4.0      xtable_1.8-4          
##  [55] reticulate_1.22        spatstat.core_2.3-2    stats4_4.1.2          
##  [58] htmlwidgets_1.5.4      httr_1.4.2             RColorBrewer_1.1-2    
##  [61] ellipsis_0.3.2         ica_1.0-2              pkgconfig_2.0.3       
##  [64] farver_2.1.0           dbplyr_2.1.1           sass_0.4.0            
##  [67] ggseqlogo_0.1          uwot_0.1.11            deldir_1.0-6          
##  [70] utf8_1.2.2             labeling_0.4.2         tidyselect_1.1.1      
##  [73] rlang_0.4.12           reshape2_1.4.4         later_1.3.0           
##  [76] cellranger_1.1.0       munsell_0.5.0          tools_4.1.2           
##  [79] cli_3.1.0              generics_0.1.1         broom_0.7.10          
##  [82] ggridges_0.5.3         evaluate_0.14          fastmap_1.1.0         
##  [85] yaml_2.2.1             goftest_1.2-3          fs_1.5.2              
##  [88] knitr_1.36             fitdistrplus_1.1-6     RANN_2.6.1            
##  [91] pbapply_1.5-0          future_1.23.0          nlme_3.1-153          
##  [94] mime_0.12              slam_0.1-49            RcppRoll_0.3.0        
##  [97] xml2_1.3.3             rstudioapi_0.13        compiler_4.1.2        
## [100] plotly_4.10.0          png_0.1-7              spatstat.utils_2.3-0  
## [103] reprex_2.0.1           tweenr_1.0.2           bslib_0.3.1           
## [106] stringi_1.7.6          highr_0.9              lattice_0.20-45       
## [109] Matrix_1.3-4           vctrs_0.3.8            pillar_1.6.4          
## [112] lifecycle_1.0.1        BiocManager_1.30.16    spatstat.geom_2.3-1   
## [115] lmtest_0.9-39          jquerylib_0.1.4        RcppAnnoy_0.0.19      
## [118] data.table_1.14.2      cowplot_1.1.1          bitops_1.0-7          
## [121] irlba_2.3.5            httpuv_1.6.4           patchwork_1.1.1       
## [124] GenomicRanges_1.46.1   R6_2.5.1               bookdown_0.24         
## [127] promises_1.2.0.1       KernSmooth_2.23-20     gridExtra_2.3         
## [130] lsa_0.73.2             IRanges_2.28.0         parallelly_1.30.0     
## [133] codetools_0.2-18       MASS_7.3-54            assertthat_0.2.1      
## [136] withr_2.4.3            qlcMatrix_0.9.7        sctransform_0.3.2     
## [139] Rsamtools_2.10.0       S4Vectors_0.32.3       GenomeInfoDbData_1.2.7
## [142] hms_1.1.1              mgcv_1.8-38            parallel_4.1.2        
## [145] grid_4.1.2             rpart_4.1-15           rmarkdown_2.11        
## [148] Rtsne_0.15             ggforce_0.3.3          lubridate_1.8.0       
## [151] shiny_1.7.1